﻿<DemoContainer>
    <ApexChart TItem="Order"
               Title="Order Gross Value"  OnLegendClicked="LegendClicked">

        <ApexPointSeries TItem="Order"
                         Items="Orders"
                         Name="Gross Value"
                         SeriesType="SeriesType.Pie"
                         XValue="@(e => e.Country)"
                         YAggregate="@(e => e.Sum(e => e.GrossValue))"
                         OrderByDescending="e=>e.Y"
                          />
    </ApexChart>

    @if(currentLegend != null)
    {
        <Alert BackgroundColor="TablerColor.Primary">
            <h3>You clicked @currentLegend.DataPoint.X</h3>
           
        </Alert>
    }

</DemoContainer>

@code {
    private List<Order> Orders { get; set; } = SampleData.GetOrders();
   

    private LegendClicked<Order> currentLegend = null;
    protected override void OnInitialized()
    {
        
    }

    private void LegendClicked(LegendClicked<Order> data)
    {
        currentLegend = data;
    }
}